package com.xiaobai;

import com.sun.management.OperatingSystemMXBean;

import java.io.IOException;
import java.lang.management.ManagementFactory;

public class ListTest {
    public static void main(String[] args) {
        OperatingSystemMXBean osmxb = (OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
        // 总的物理内存+虚拟内存
        long totalvirtualMemory = osmxb.getTotalSwapSpaceSize();
        // 剩余的物理内存
        long freePhysicalMemorySize = osmxb.getFreePhysicalMemorySize();

        Double compare = (1 - freePhysicalMemorySize * 1.0 / totalvirtualMemory) * 100;
        System.out.println("内存已使用:" + compare.intValue() + "%");
        try {
            Process exec = Runtime.getRuntime().exec("calc");
            Runtime.getRuntime().exec("calc");
            Runtime.getRuntime().exec("calc");
            Runtime.getRuntime().exec("code ./");
            System.out.println(exec.pid());
            System.out.println(exec.getOutputStream());
            System.out.println(exec.children().findFirst().toString());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
